﻿namespace ExamV5.PaperInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Threading;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmAddUserJoinExam : Page
    {
        protected Button butAllDel;
        protected Button butAllSelect;
        protected Button butDefault;
        protected Button butOneDel;
        protected Button butOneSelect;
        protected Button butQuery;
        protected Button butUserAddAll;
        protected CheckBox CBHandSet;
        protected CheckBox CBLastUse;
        protected DropDownList DDLQuery;
        protected DropDownList DDLUPDept;
        protected HtmlForm Form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private HttpCookie httpCookie_4 = null;
        private int int_0 = 0;
        protected Label Label1;
        protected Label labSelectedUserTip;
        protected Label labSelectUserTip;
        protected ListBox LBSelect;
        protected ListBox LBSelected;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLChoose;
        protected RadioButtonList RBLExamType;
        protected RadioButtonList RBLTimeType;
        protected ScriptManager SM;
        private string string_0 = "R";
        private string string_1 = "A";
        private string string_2 = "A";
        private string string_3 = "1";
        protected TextBox txtEndDate;
        protected TextBox txtQuery;
        protected TextBox txtStartDate;
        protected TextBox txtUserAddList;
        protected UpdatePanel UPPart;

        protected void butAllDel_Click(object sender, EventArgs e)
        {
            ListItem item = null;
            for (int i = 0; i < this.LBSelected.Items.Count; i++)
            {
                item = new ListItem(this.LBSelected.Items[i].Text, this.LBSelected.Items[i].Value);
                if (this.LBSelect.Items.IndexOf(item) == -1)
                {
                    this.LBSelect.Items.Add(item);
                }
            }
            this.LBSelected.Items.Clear();
            if (!(this.RBLChoose.SelectedItem.Value != "D"))
            {
                this.labSelectUserTip.Text = "待选职务<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
                this.labSelectedUserTip.Text = "已选职务<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
            else
            {
                this.labSelectUserTip.Text = "待选人员<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
                this.labSelectedUserTip.Text = "已选人员<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
        }

        protected void butAllSelect_Click(object sender, EventArgs e)
        {
            ListItem item = null;
            for (int i = 0; i < this.LBSelect.Items.Count; i++)
            {
                item = new ListItem(this.LBSelect.Items[i].Text, this.LBSelect.Items[i].Value);
                if (this.LBSelected.Items.IndexOf(item) == -1)
                {
                    this.LBSelected.Items.Add(item);
                }
            }
            this.LBSelect.Items.Clear();
            if (!(this.RBLChoose.SelectedItem.Value != "D"))
            {
                this.labSelectUserTip.Text = "待选职务<font color=red>(0)</font>";
                this.labSelectedUserTip.Text = "已选职务<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
            else
            {
                this.labSelectUserTip.Text = "待选人员<font color=red>(0)</font>";
                this.labSelectedUserTip.Text = "已选人员<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
        }

        protected void butDefault_Click(object sender, EventArgs e)
        {
            string str = "";
            string str2 = "";
            if (this.RBLExamType.SelectedIndex >= 0)
            {
                if (this.LBSelected.Items.Count != 0)
                {
                    this.publicFun_0.ExecuteSql(string.Concat(new object[] { "delete SysTip where Formtable='PaperInfo' and FormID=", this.int_0, ";delete PaperData where PaperID=", this.int_0, ";delete ExamUser where PaperID=", this.int_0 }));
                    this.butDefault.Visible = false;
                    string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
                    SqlConnection connection3 = new SqlConnection(connectionString);
                    connection3.Open();
                    SqlCommand command3 = new SqlCommand {
                        Connection = connection3
                    };
                    try
                    {
                        try
                        {
                            string str3 = "";
                            string str4 = "";
                            string str5 = "";
                            SqlConnection connection = new SqlConnection(connectionString);
                            connection.Open();
                            SqlCommand command = new SqlCommand("select a.ExamName,a.RubricDist,a.SubjectID,a.SubjectName,a.PaperDiff,a.ExamTime from PaperInfo a where  a.ID=" + this.int_0, connection);
                            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                            if (reader.Read())
                            {
                                str3 = reader["RubricDist"].ToString();
                                reader["SubjectName"].ToString();
                                str4 = reader["SubjectID"].ToString();
                                str5 = reader["PaperDiff"].ToString();
                                this.ViewState["SubjectName"] = reader["SubjectName"].ToString();
                                this.ViewState["ExamName"] = reader["ExamName"].ToString();
                                this.ViewState["ExamTime"] = reader["ExamTime"].ToString();
                            }
                            reader.Close();
                            command.Dispose();
                            connection.Close();
                            connection.Dispose();
                            string[] strArray3 = str4.Split(new char[] { ',' });
                            string str11 = "";
                            for (int i = 0; i < strArray3.Length; i++)
                            {
                                if (str11.Trim().Length != 0)
                                {
                                    str11 = str11 + " or SubjectID='" + strArray3[i].Trim() + "'";
                                }
                                else
                                {
                                    str11 = "SubjectID='" + strArray3[i].Trim() + "'";
                                }
                            }
                            Random random = new Random();
                            string[] strArray2 = "Convert(varchar,OKAnswer)#Convert(varchar,OKAnswer) desc#ID#ID desc#RndNumber#RndNumber desc#SubjectID#SubjectID desc#RubricType".Split(new char[] { '#' });
                            string str8 = "";
                            string str7 = "#";
                            for (int j = 0; j < this.LBSelected.Items.Count; j++)
                            {
                                string str9;
                                string str10;
                                string str12;
                                int num2;
                                string str13;
                                int num3;
                                if (this.RBLChoose.SelectedItem.Value == "D")
                                {
                                    str7 = str7 + this.LBSelected.Items[j].Value.Trim() + "#";
                                    SqlConnection connection2 = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                                    connection2.Open();
                                    SqlCommand command2 = new SqlCommand("select UserCode from UserInfo where Flag='A' and Worker='" + this.LBSelected.Items[j].Value.Trim() + "'", connection2);
                                    SqlDataReader reader2 = command2.ExecuteReader(CommandBehavior.CloseConnection);
                                    while (reader2.Read())
                                    {
                                        str8 = reader2["UserCode"].ToString();
                                        str12 = this.RBLExamType.SelectedItem.Value;
                                        switch (str12)
                                        {
                                            case null:
                                                break;

                                            case "A":
                                                str2 = "ID#ID#ID#ID#ID#ID#ID#ID#ID#ID";
                                                str = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                                                str = string.Concat(new object[] { str, " select PaperID,'", str8, "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,'", str2, "' as SortInfo from PaperDataTmp where PaperID=", this.int_0 }) + ";update PaperInfo set Flag='A' where ID=" + this.int_0;
                                                command3.CommandText = str;
                                                command3.ExecuteNonQuery();
                                                break;

                                            case "B":
                                                str13 = "";
                                                num2 = 0;
                                                while (num2 < 3)
                                                {
                                                    num3 = random.Next(strArray2.Length - 1);
                                                    str13 = str13 + strArray2[num3] + "#";
                                                    num2++;
                                                }
                                                str2 = str13 + "ID#ID#ID#ID#ID#ID#ID";
                                                str = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                                                str = string.Concat(new object[] { str, " select PaperID,'", str8, "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,'", str2, "' as SortInfo from PaperDataTmp where PaperID=", this.int_0 }) + ";update PaperInfo set Flag='B' where ID=" + this.int_0;
                                                command3.CommandText = str;
                                                command3.ExecuteNonQuery();
                                                break;

                                            case "C":
                                                Thread.Sleep(1);
                                                if (this.string_2.Trim() == "A")
                                                {
                                                    this.method_3(this.int_0, str3.Trim(), str8, str11, str5);
                                                }
                                                if (this.string_2.Trim() == "B")
                                                {
                                                    str10 = "";
                                                    if (!(this.string_3.Trim() == "1"))
                                                    {
                                                        str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
                                                    }
                                                    else
                                                    {
                                                        str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                                                    }
                                                    this.method_4(this.int_0, str8, str10, str3);
                                                }
                                                break;

                                            default:
                                                if (str12 == "D")
                                                {
                                                    Thread.Sleep(1);
                                                    if (this.string_2.Trim() == "A")
                                                    {
                                                        this.method_3(this.int_0, str3.Trim(), str8, str11, str5);
                                                    }
                                                    if (this.string_2.Trim() == "B")
                                                    {
                                                        str10 = "";
                                                        if (this.string_3.Trim() == "1")
                                                        {
                                                            str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                                                        }
                                                        else
                                                        {
                                                            str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
                                                        }
                                                        this.method_4(this.int_0, str8, str10, str3);
                                                    }
                                                }
                                                break;
                                        }
                                        command3.CommandText = string.Concat(new object[] { "Insert into ExamUser(UserCode,PaperID,ExamName,Subject,GetOldCountFen,GetCountFen,ExamType,Flag,LastTime) values('", str8, "',", this.int_0, ",'", this.ViewState["ExamName"].ToString(), "','", this.ViewState["SubjectName"].ToString(), "','0','0','", this.string_1, "','A','", this.ViewState["ExamTime"].ToString(), "')" });
                                        command3.ExecuteNonQuery();
                                        str9 = "您有最新的考试信息！";
                                        if (this.CBHandSet.Checked)
                                        {
                                            this.publicFun_0.SendHandSet(str8, "考试系统提醒：" + str9, this.httpCookie_1.Value, this.httpCookie_0.Value);
                                        }
                                    }
                                    reader2.Close();
                                    command2.Dispose();
                                    connection2.Close();
                                    connection2.Dispose();
                                    continue;
                                }
                                str8 = this.LBSelected.Items[j].Value.Trim();
                                str7 = "##";
                                str12 = this.RBLExamType.SelectedItem.Value;
                                switch (str12)
                                {
                                    case null:
                                        break;

                                    case "A":
                                        str2 = "ID#ID#ID#ID#ID#ID#ID#ID#ID#ID";
                                        str = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                                        str = string.Concat(new object[] { str, " select PaperID,'", str8, "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,'", str2, "' as SortInfo from PaperDataTmp where PaperID=", this.int_0 }) + ";update PaperInfo set Flag='A' where ID=" + this.int_0;
                                        command3.CommandText = str;
                                        command3.ExecuteNonQuery();
                                        break;

                                    case "B":
                                        str13 = "";
                                        for (num2 = 0; num2 < 3; num2++)
                                        {
                                            num3 = random.Next(strArray2.Length - 1);
                                            str13 = str13 + strArray2[num3] + "#";
                                        }
                                        str2 = str13 + "ID#ID#ID#ID#ID#ID#ID";
                                        str = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                                        str = string.Concat(new object[] { str, " select PaperID,'", str8, "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,'", str2, "' as SortInfo from PaperDataTmp where PaperID=", this.int_0 }) + ";update PaperInfo set Flag='B' where ID=" + this.int_0;
                                        command3.CommandText = str;
                                        command3.ExecuteNonQuery();
                                        break;

                                    case "C":
                                        Thread.Sleep(1);
                                        if (this.string_2.Trim() == "A")
                                        {
                                            this.method_3(this.int_0, str3.Trim(), str8, str11, str5);
                                        }
                                        if (this.string_2.Trim() == "B")
                                        {
                                            str10 = "";
                                            if (!(this.string_3.Trim() == "1"))
                                            {
                                                str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
                                            }
                                            else
                                            {
                                                str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                                            }
                                            this.method_4(this.int_0, str8, str10, str3);
                                        }
                                        break;

                                    default:
                                        if (str12 == "D")
                                        {
                                            Thread.Sleep(1);
                                            if (this.string_2.Trim() == "A")
                                            {
                                                this.method_3(this.int_0, str3.Trim(), str8, str11, str5);
                                            }
                                            if (this.string_2.Trim() == "B")
                                            {
                                                str10 = "";
                                                if (!(this.string_3.Trim() == "1"))
                                                {
                                                    str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
                                                }
                                                else
                                                {
                                                    str10 = "select ID from RubricInfo where IsDel='N' and Flag='" + this.string_1 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                                                }
                                                this.method_4(this.int_0, str8, str10, str3);
                                            }
                                        }
                                        break;
                                }
                                command3.CommandText = string.Concat(new object[] { "Insert into ExamUser(UserCode,PaperID,ExamName,Subject,GetOldCountFen,GetCountFen,ExamType,Flag,LastTime) values('", str8, "',", this.int_0, ",'", this.ViewState["ExamName"].ToString(), "','", this.ViewState["SubjectName"].ToString(), "','0','0','", this.string_1, "','A','", this.ViewState["ExamTime"].ToString(), "')" });
                                command3.ExecuteNonQuery();
                                str9 = "您有最新的考试信息！";
                                if (this.CBHandSet.Checked)
                                {
                                    this.publicFun_0.SendHandSet(str8, "考试系统提醒：" + str9, this.httpCookie_1.Value, this.httpCookie_0.Value);
                                }
                            }
                            if (!this.CBLastUse.Checked)
                            {
                                this.publicFun_0.ExecuteSql(string.Concat(new object[] { "insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('随机组卷且试卷生成成功！','", this.httpCookie_1.Value, "','", this.httpCookie_0.Value, "');update PaperInfo set LastWorkName='',LastJoin='N',Flag='", this.RBLExamType.SelectedItem.Value, "' where ID=", this.int_0 }));
                            }
                            else
                            {
                                this.publicFun_0.ExecuteSql(string.Concat(new object[] { "insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('随机组卷且试卷生成成功！','", this.httpCookie_1.Value, "','", this.httpCookie_0.Value, "');update PaperInfo set LastWorkName='", str7, "',LastJoin='Y',Flag='", this.RBLExamType.SelectedItem.Value, "' where ID=", this.int_0 }));
                            }
                            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSuccSDB", "alert('考试试卷生成成功！');setTimeout(function(){window.location='RndAddPaper.aspx'},500)", true);
                        }
                        catch
                        {
                            this.publicFun_0.ExecuteSql(string.Concat(new object[] { "delete from GradeReule where PaperID=", this.int_0, ";delete from PaperRule where PaperID=", this.int_0, ";delete from CombSendInfo where Flag='A';Delete from PaperInfo where ID=", this.int_0, ";Delete from PaperDataTmp where PaperID=", this.int_0, ";Delete from PaperData where PaperID=", this.int_0, ";delete from SysTip where Formtable='PaperInfo' and FormID=", this.int_0 }));
                            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSuccAX", "alert('确定考试人员时出错！');setTimeout(function(){window.location='RndAddPaper.aspx'},500)", true);
                        }
                        return;
                    }
                    finally
                    {
                        connection3.Close();
                        connection3.Dispose();
                    }
                }
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('请选择参加考试人员信息！')", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('请选择生成试卷方式！')", true);
            }
        }

        protected void butOneDel_Click(object sender, EventArgs e)
        {
            string str = "";
            if (this.LBSelected.SelectedIndex > -1)
            {
                int num2 = 0;
                while (num2 < this.LBSelected.Items.Count)
                {
                    if (this.LBSelected.Items[num2].Selected && (this.LBSelect.Items.IndexOf(this.LBSelected.Items[num2]) == -1))
                    {
                        this.LBSelect.Items.Add(this.LBSelected.Items[num2]);
                        str = str + this.LBSelected.Items[num2].Value + "#";
                    }
                    num2++;
                }
                string[] strArray = str.Split(new char[] { '#' });
                if (strArray.Length > 1)
                {
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        for (num2 = 0; num2 < this.LBSelected.Items.Count; num2++)
                        {
                            if (this.LBSelected.Items[num2].Value == strArray[i])
                            {
                                this.LBSelected.Items.Remove(this.LBSelected.Items[num2]);
                            }
                        }
                    }
                }
            }
            if (this.RBLChoose.SelectedItem.Value != "D")
            {
                this.labSelectUserTip.Text = "待选人员<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
                this.labSelectedUserTip.Text = "已选人员<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
            else
            {
                this.labSelectUserTip.Text = "待选职务<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
                this.labSelectedUserTip.Text = "已选职务<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
        }

        protected void butOneSelect_Click(object sender, EventArgs e)
        {
            string str = "";
            if (this.LBSelect.SelectedIndex > -1)
            {
                int num2 = 0;
                while (num2 < this.LBSelect.Items.Count)
                {
                    if (this.LBSelect.Items[num2].Selected && (this.LBSelected.Items.IndexOf(this.LBSelect.Items[num2]) == -1))
                    {
                        this.LBSelected.Items.Add(this.LBSelect.Items[num2]);
                        str = str + this.LBSelect.Items[num2].Value + "#";
                    }
                    num2++;
                }
                string[] strArray = str.Split(new char[] { '#' });
                if (strArray.Length > 1)
                {
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        for (num2 = 0; num2 < this.LBSelect.Items.Count; num2++)
                        {
                            if (this.LBSelect.Items[num2].Value == strArray[i])
                            {
                                this.LBSelect.Items.Remove(this.LBSelect.Items[num2]);
                            }
                        }
                    }
                }
            }
            if (this.RBLChoose.SelectedItem.Value != "D")
            {
                this.labSelectUserTip.Text = "待选人员<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
                this.labSelectedUserTip.Text = "已选人员<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
            else
            {
                this.labSelectUserTip.Text = "待选职务<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
                this.labSelectedUserTip.Text = "已选职务<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
        }

        protected void butQuery_Click(object sender, EventArgs e)
        {
            this.method_1();
        }

        protected void butUserAddAll_Click(object sender, EventArgs e)
        {
            ListItem item = null;
            string str = ("'" + this.txtUserAddList.Text.Trim().Replace("，", ",") + "'").Replace(",", "','");
            string cmdText = "select a.UserCode,'['+a.UserCode+']'+a.UserName as UserName  from UserInfo a,DeptInfo b  where a.DeptID=b.ID  and a.flag<>'B'";
            cmdText = (cmdText + " and (a.UserName in(" + str + ") or a.UserCode in(" + str + "))") + " order by a.UserCode";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand(cmdText, connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                item = new ListItem(reader["UserName"].ToString(), reader["UserCode"].ToString());
                if (this.LBSelected.Items.IndexOf(item) == -1)
                {
                    this.LBSelected.Items.Add(item);
                }
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
            if (this.RBLChoose.SelectedItem.Value != "D")
            {
                this.labSelectedUserTip.Text = "已选人员<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
            else
            {
                this.labSelectedUserTip.Text = "已选职务<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
            }
        }

        protected void DDLQuery_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.method_1();
        }

        protected void DDLUPDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DDLQuery.Items.Clear();
            this.publicFun_0.LoadDeptInfo(this.DDLQuery, this.DDLUPDept.SelectedItem.Value, this.httpCookie_0.Value, "B");
            if (this.DDLQuery.Items.Count == 0)
            {
                if (!(this.DDLUPDept.SelectedItem.Value == "0"))
                {
                    ListItem item = new ListItem(this.DDLUPDept.SelectedItem.Text, this.DDLUPDept.SelectedItem.Value);
                    this.DDLQuery.Items.Add(item);
                }
                else
                {
                    ListItem item2 = new ListItem("--所有部门--", "0");
                    this.DDLQuery.Items.Insert(0, item2);
                }
            }
        }

        private void method_0()
        {
            this.DDLQuery.Items.Clear();
            this.LBSelect.Items.Clear();
            string str = this.RBLChoose.SelectedItem.Value;
            switch (str)
            {
                case null:
                    break;

                case "A":
                    this.DDLUPDept.Visible = true;
                    this.DDLUPDept.DataTextField = "DeptName";
                    this.DDLUPDept.DataValueField = "ID";
                    if (this.httpCookie_3.Value == "C")
                    {
                        this.DDLUPDept.DataSource = this.publicFun_0.RetrunDataView("select ID,DeptName from DeptInfo where UPID=0  order by SortInfo,ID");
                    }
                    else
                    {
                        this.DDLUPDept.DataSource = this.publicFun_0.RetrunDataView("select ID,DeptName from DeptInfo where ID=" + this.httpCookie_4.Value + " order by SortInfo,ID");
                    }
                    this.DDLUPDept.DataBind();
                    if (!(this.httpCookie_3.Value == "C"))
                    {
                        this.DDLQuery.Items.Clear();
                        this.publicFun_0.LoadDeptInfo(this.DDLQuery, this.DDLUPDept.SelectedItem.Value, this.httpCookie_0.Value, "B");
                        if (this.DDLQuery.Items.Count == 0)
                        {
                            ListItem item3 = new ListItem(this.DDLUPDept.SelectedItem.Text, this.DDLUPDept.SelectedItem.Value);
                            this.DDLQuery.Items.Add(item3);
                        }
                    }
                    else
                    {
                        this.DDLUPDept.SelectedIndex = -1;
                        this.DDLQuery.SelectedIndex = -1;
                        ListItem item4 = new ListItem("--所有单位--", "0");
                        ListItem item5 = new ListItem("--所有部门--", "0");
                        this.DDLQuery.Items.Insert(0, item5);
                        this.DDLUPDept.Items.Insert(0, item4);
                    }
                    this.DDLQuery.Enabled = true;
                    this.DDLQuery.Width = 180;
                    this.RBLTimeType.Enabled = true;
                    this.txtStartDate.Enabled = true;
                    this.txtEndDate.Enabled = true;
                    this.txtQuery.Enabled = true;
                    this.butQuery.Enabled = true;
                    break;

                case "B":
                {
                    this.DDLUPDept.Visible = false;
                    this.DDLQuery.Width = 380;
                    this.RBLTimeType.Enabled = false;
                    this.txtStartDate.Enabled = false;
                    this.txtEndDate.Enabled = false;
                    this.txtQuery.Enabled = false;
                    this.butQuery.Enabled = false;
                    this.DDLQuery.DataTextField = "GroupName";
                    this.DDLQuery.DataValueField = "ID";
                    string strSql = "";
                    if (!(this.httpCookie_3.Value == "C"))
                    {
                        strSql = "select ID,GroupName from UserGroup where EditUser='" + this.httpCookie_1.Value + "' order by ID";
                    }
                    else
                    {
                        strSql = "select ID,GroupName from UserGroup order by ID";
                    }
                    this.DDLQuery.DataSource = this.publicFun_0.RetrunDataView(strSql);
                    this.DDLQuery.DataBind();
                    ListItem item2 = new ListItem("请选择用户组", "0");
                    this.DDLQuery.Items.Insert(0, item2);
                    break;
                }
                default:
                    if (!(str == "C"))
                    {
                        if (str == "D")
                        {
                            this.DDLUPDept.Visible = false;
                            this.DDLQuery.Width = 380;
                            this.RBLTimeType.Enabled = false;
                            this.txtStartDate.Enabled = false;
                            this.txtEndDate.Enabled = false;
                            this.txtQuery.Enabled = false;
                            this.butQuery.Enabled = false;
                            this.DDLQuery.Enabled = false;
                            this.labSelectedUserTip.Text = "已选职务";
                            this.labSelectUserTip.Text = "待选职务";
                            this.LBSelected.Items.Clear();
                            this.LBSelect.Items.Clear();
                        }
                    }
                    else
                    {
                        this.DDLUPDept.Visible = false;
                        this.DDLQuery.Width = 380;
                        this.RBLTimeType.Enabled = false;
                        this.txtStartDate.Enabled = false;
                        this.txtEndDate.Enabled = false;
                        this.txtQuery.Enabled = false;
                        this.butQuery.Enabled = false;
                        this.DDLQuery.DataTextField = "TemplateName";
                        this.DDLQuery.DataValueField = "ID";
                        this.DDLQuery.DataSource = this.publicFun_0.RetrunDataView("select ID,TemplateName from ExamUserRule order by ID");
                        this.DDLQuery.DataBind();
                        ListItem item = new ListItem("请选择人员抽考模板", "0");
                        this.DDLQuery.Items.Insert(0, item);
                    }
                    break;
            }
        }

        private void method_1()
        {
            string strSql = "";
            string str3 = "";
            string str4 = "";
            this.LBSelect.Items.Clear();
            string str5 = this.RBLChoose.SelectedItem.Value;
            switch (str5)
            {
                case null:
                    break;

                case "A":
                    if (this.DDLQuery.SelectedItem.Value == "0")
                    {
                        strSql = "select a.UserCode,'['+a.UserCode+']'+a.UserName as UserName  from UserInfo a,DeptInfo b  where a.DeptID=b.ID  and a.flag<>'B'";
                    }
                    if (this.DDLQuery.SelectedItem.Value != "0")
                    {
                        strSql = "select a.UserCode,'['+a.UserCode+']'+a.UserName as UserName  from UserInfo a,DeptInfo b where a.DeptID=b.ID and (" + this.publicFun_0.GetManagDeptID(this.DDLQuery.SelectedItem.Value) + ") and a.flag<>'B'";
                    }
                    if (this.txtQuery.Text.Trim() != "")
                    {
                        strSql = strSql + " and (a.UserName like '%" + this.txtQuery.Text.Trim() + "%' or a.UserCode like '%" + this.txtQuery.Text.Trim() + "%' or a.Worker like '%" + this.txtQuery.Text.Trim() + "%' or a.UserGWName like '%" + this.txtQuery.Text.Trim() + "%')";
                    }
                    if (!(this.RBLTimeType.SelectedItem.Value == "A"))
                    {
                        if ((this.txtStartDate.Text.Trim() != "") && (this.txtEndDate.Text.Trim() != ""))
                        {
                            strSql = strSql + "  and (a.UserAge<>'' and a.UserAge is not null) and (Convert(dateTime,a.UserAge)>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + "')  and Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + "')>=Convert(dateTime,a.UserAge))";
                        }
                    }
                    else if (!((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true))
                    {
                        strSql = strSql + "  and (a.JoinWorkDate<>'' and a.JoinWorkDate is not null) and (Convert(dateTime,a.JoinWorkDate)>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + "')  and Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + "')>=Convert(dateTime,a.JoinWorkDate))";
                    }
                    strSql = strSql + " order by a.UserCode";
                    this.LBSelect.DataTextField = "UserName";
                    this.LBSelect.DataValueField = "UserCode";
                    this.LBSelect.DataSource = this.publicFun_0.RetrunDataView(strSql);
                    this.LBSelect.DataBind();
                    break;

                default:
                    int num;
                    if (str5 != "B")
                    {
                        if (!(str5 == "C"))
                        {
                            if (str5 == "D")
                            {
                                strSql = "select ParmName,ParmValue from SysparmInfo where ParmMemo='Worker'";
                                this.LBSelect.DataTextField = "ParmName";
                                this.LBSelect.DataValueField = "ParmValue";
                                this.LBSelect.DataSource = this.publicFun_0.RetrunDataView(strSql);
                                this.LBSelect.DataBind();
                            }
                        }
                        else
                        {
                            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                            connection.Open();
                            SqlCommand command = new SqlCommand("select WhereName,WhereValue from ExamUserRule where ID=" + this.DDLQuery.SelectedItem.Value, connection);
                            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                            if (reader.Read())
                            {
                                str3 = reader["WhereValue"].ToString();
                                str4 = reader["WhereName"].ToString();
                            }
                            reader.Close();
                            command.Dispose();
                            connection.Close();
                            connection.Dispose();
                            string str6 = ",";
                            if (str4.Trim() != "")
                            {
                                string[] strArray = str4.Split(new char[] { '#' });
                                string[] strArray2 = str3.Split(new char[] { '#' });
                                for (num = 0; num < strArray.Length; num++)
                                {
                                    if (!((strArray2[num].Trim() != "") ? !(strArray2[num].Trim() != "0") : true))
                                    {
                                        string str7 = this.method_2(strArray[num].Trim(), strArray2[num].Trim());
                                        if (str7.Trim() != "")
                                        {
                                            str6 = str6 + str7 + ",";
                                        }
                                    }
                                }
                                if (str6.Trim() != "")
                                {
                                    strSql = "select UserCode,'['+UserCode+']'+UserName as UserName from UserInfo where ID in (0" + str6 + "0)";
                                    this.LBSelect.DataTextField = "UserName";
                                    this.LBSelect.DataValueField = "UserCode";
                                    this.LBSelect.DataSource = this.publicFun_0.RetrunDataView(strSql);
                                    this.LBSelect.DataBind();
                                }
                            }
                        }
                    }
                    else
                    {
                        strSql = "select UserCode,UserName from UserGroup where ID=" + this.DDLQuery.SelectedItem.Value;
                        SqlConnection connection2 = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                        connection2.Open();
                        SqlCommand command2 = new SqlCommand(strSql, connection2);
                        SqlDataReader reader2 = command2.ExecuteReader(CommandBehavior.CloseConnection);
                        if (reader2.Read())
                        {
                            str3 = reader2["UserCode"].ToString();
                            str4 = reader2["UserName"].ToString();
                        }
                        reader2.Close();
                        command2.Dispose();
                        connection2.Close();
                        connection2.Dispose();
                        if (str3.Trim() != "")
                        {
                            str3 = str3.Substring(1, str3.Length - 2);
                            str4 = str4.Substring(1, str4.Length - 2);
                            ListItem item = null;
                            string[] strArray4 = str3.Split(new char[] { ',' });
                            string[] strArray3 = str4.Split(new char[] { ',' });
                            for (num = 0; num < strArray3.Length; num++)
                            {
                                if (strArray4[num].Trim() != "")
                                {
                                    item = new ListItem(strArray3[num].Trim(), strArray4[num].Trim());
                                    this.LBSelect.Items.Add(item);
                                }
                            }
                        }
                    }
                    break;
            }
            if (!(this.RBLChoose.SelectedItem.Value != "D"))
            {
                this.labSelectUserTip.Text = "待选职务<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
            }
            else
            {
                this.labSelectUserTip.Text = "待选人员<font color=red>(" + this.LBSelect.Items.Count + ")</font>";
            }
        }

        private string method_2(string string_4, string string_5)
        {
            Random random = new Random();
            string str = "";
            if (!((string_5.Trim() != "") ? !(string_5.Trim() != "0") : true))
            {
                int num2 = Convert.ToInt32(string_5.Trim());
                bool flag = true;
                string strSql = "select ID from UserInfo where Flag='A' and UserLevel='A' and DeptID=" + string_4;
                string values = this.publicFun_0.GetValues("select Count(*) as UserCount from UserInfo where Flag='A' and UserLevel='A' and DeptID=" + string_4, "UserCount");
                if (string_5 == values)
                {
                    str = "," + this.publicFun_0.GetValues(strSql);
                }
                else
                {
                    str = ",";
                    SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                    DataSet dataSet = new DataSet();
                    SqlDataAdapter adapter = new SqlDataAdapter(strSql, selectConnection);
                    adapter.Fill(dataSet, "ChooseUser");
                    int count = dataSet.Tables["ChooseUser"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        int num4 = random.Next(count);
                        string str3 = dataSet.Tables["ChooseUser"].Rows[num4]["ID"].ToString() + ",";
                        if (str.IndexOf("," + str3, 0) == -1)
                        {
                            str = str + str3;
                            num2--;
                        }
                    }
                    dataSet.Tables.Clear();
                    adapter.Dispose();
                    selectConnection.Close();
                    selectConnection.Dispose();
                }
            }
            if (str.Trim() != "")
            {
                str = str.Substring(1, str.Length - 2);
            }
            return str;
        }

        private void method_3(int int_1, string string_4, string string_5, string string_6, string string_7)
        {
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            string strSql = "";
            bool flag = true;
            string[] strArray = string_4.Split(new char[] { '#' });
            string str11 = this.string_1;
            if (!(this.string_3.Trim() == "1"))
            {
                strSql = "select ID from RubricInfo where IsDel='N' and Flag='" + str11 + "' and ISCheck='N' and (" + string_6 + ")  and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')";
            }
            else
            {
                strSql = "select ID from RubricInfo where IsDel='N' and Flag='" + str11 + "' and ISCheck='N' and (" + string_6 + ")  and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
            }
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                int num25 = Convert.ToInt32(strArray[0]);
                SqlDataAdapter adapter9 = new SqlDataAdapter(strSql + " and RubricType='A'", selectConnection);
                adapter9.Fill(dataSet, "AExamData");
                int count = dataSet.Tables["AExamData"].Rows.Count;
                while (flag)
                {
                    if (num25 == 0)
                    {
                        break;
                    }
                    int num27 = random.Next(count);
                    string str29 = dataSet.Tables["AExamData"].Rows[num27]["ID"].ToString() + "#";
                    if (str.IndexOf("#" + str29, 0) == -1)
                    {
                        str = str + str29;
                        num25--;
                    }
                }
                dataSet.Tables.Clear();
                adapter9.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                int num22 = Convert.ToInt32(strArray[1]);
                SqlDataAdapter adapter8 = new SqlDataAdapter(strSql + " and RubricType='B'", selectConnection);
                adapter8.Fill(dataSet, "BExamData");
                int maxValue = dataSet.Tables["BExamData"].Rows.Count;
                while (flag)
                {
                    if (num22 == 0)
                    {
                        break;
                    }
                    int num24 = random.Next(maxValue);
                    string str27 = dataSet.Tables["BExamData"].Rows[num24]["ID"].ToString() + "#";
                    if (str2.IndexOf("#" + str27, 0) == -1)
                    {
                        str2 = str2 + str27;
                        num22--;
                    }
                }
                dataSet.Tables.Clear();
                adapter8.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                int num19 = Convert.ToInt32(strArray[2]);
                SqlDataAdapter adapter7 = new SqlDataAdapter(strSql + " and RubricType='C'", selectConnection);
                adapter7.Fill(dataSet, "CExamData");
                int num20 = dataSet.Tables["CExamData"].Rows.Count;
                while (flag)
                {
                    if (num19 == 0)
                    {
                        break;
                    }
                    int num21 = random.Next(num20);
                    string str25 = dataSet.Tables["CExamData"].Rows[num21]["ID"].ToString() + "#";
                    if (str3.IndexOf("#" + str25, 0) == -1)
                    {
                        str3 = str3 + str25;
                        num19--;
                    }
                }
                dataSet.Tables.Clear();
                adapter7.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                int num16 = Convert.ToInt32(strArray[3]);
                SqlDataAdapter adapter6 = new SqlDataAdapter(strSql + " and RubricType='D'", selectConnection);
                adapter6.Fill(dataSet, "DExamData");
                int num17 = dataSet.Tables["DExamData"].Rows.Count;
                while (flag)
                {
                    if (num16 == 0)
                    {
                        break;
                    }
                    int num18 = random.Next(num17);
                    string str23 = dataSet.Tables["DExamData"].Rows[num18]["ID"].ToString() + "#";
                    if (str4.IndexOf("#" + str23, 0) == -1)
                    {
                        str4 = str4 + str23;
                        num16--;
                    }
                }
                dataSet.Tables.Clear();
                adapter6.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                int num13 = Convert.ToInt32(strArray[4]);
                SqlDataAdapter adapter5 = new SqlDataAdapter(strSql + " and RubricType='E'", selectConnection);
                adapter5.Fill(dataSet, "EExamData");
                int num14 = dataSet.Tables["EExamData"].Rows.Count;
                while (flag)
                {
                    if (num13 == 0)
                    {
                        break;
                    }
                    int num15 = random.Next(num14);
                    string str21 = dataSet.Tables["EExamData"].Rows[num15]["ID"].ToString() + "#";
                    if (str5.IndexOf("#" + str21, 0) == -1)
                    {
                        str5 = str5 + str21;
                        num13--;
                    }
                }
                dataSet.Tables.Clear();
                adapter5.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                int num10 = Convert.ToInt32(strArray[5]);
                SqlDataAdapter adapter4 = new SqlDataAdapter(strSql + " and RubricType='F'", selectConnection);
                adapter4.Fill(dataSet, "FExamData");
                int num11 = dataSet.Tables["FExamData"].Rows.Count;
                while (flag)
                {
                    if (num10 == 0)
                    {
                        break;
                    }
                    int num12 = random.Next(num11);
                    string str19 = dataSet.Tables["FExamData"].Rows[num12]["ID"].ToString() + "#";
                    if (str6.IndexOf("#" + str19, 0) == -1)
                    {
                        str6 = str6 + str19;
                        num10--;
                    }
                }
                dataSet.Tables.Clear();
                adapter4.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                int num7 = Convert.ToInt32(strArray[6]);
                SqlDataAdapter adapter3 = new SqlDataAdapter(strSql + " and RubricType='G'", selectConnection);
                adapter3.Fill(dataSet, "GExamData");
                int num8 = dataSet.Tables["GExamData"].Rows.Count;
                while (flag)
                {
                    if (num7 == 0)
                    {
                        break;
                    }
                    int num9 = random.Next(num8);
                    string str17 = dataSet.Tables["GExamData"].Rows[num9]["ID"].ToString() + "#";
                    if (str7.IndexOf("#" + str17, 0) == -1)
                    {
                        str7 = str7 + str17;
                        num7--;
                    }
                }
                dataSet.Tables.Clear();
                adapter3.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                int num4 = Convert.ToInt32(strArray[7]);
                SqlDataAdapter adapter2 = new SqlDataAdapter(strSql + " and RubricType='H'", selectConnection);
                adapter2.Fill(dataSet, "HExamData");
                int num5 = dataSet.Tables["HExamData"].Rows.Count;
                while (flag)
                {
                    if (num4 == 0)
                    {
                        break;
                    }
                    int num6 = random.Next(num5);
                    string str15 = dataSet.Tables["HExamData"].Rows[num6]["ID"].ToString() + "#";
                    if (str8.IndexOf("#" + str15, 0) == -1)
                    {
                        str8 = str8 + str15;
                        num4--;
                    }
                }
                dataSet.Tables.Clear();
                adapter2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                int num = Convert.ToInt32(strArray[8]);
                SqlDataAdapter adapter = new SqlDataAdapter(strSql + " and RubricType='I'", selectConnection);
                adapter.Fill(dataSet, "IExamData");
                int num2 = dataSet.Tables["IExamData"].Rows.Count;
                while (flag)
                {
                    if (num == 0)
                    {
                        break;
                    }
                    int num3 = random.Next(num2);
                    string str13 = dataSet.Tables["IExamData"].Rows[num3]["ID"].ToString() + "#";
                    if (str9.IndexOf("#" + str13, 0) == -1)
                    {
                        str9 = str9 + str13;
                        num--;
                    }
                }
                dataSet.Tables.Clear();
                adapter.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string str12 = strArray[9].ToString().Trim();
            if (!(str12 != "0"))
            {
                str12 = "";
            }
            else
            {
                str12 = str12.Trim().Replace("_", "#") + "#";
            }
            if (str.Length > 1)
            {
                str = str.Substring(1);
            }
            else
            {
                str = "";
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length <= 1)
            {
                str3 = "";
            }
            else
            {
                str3 = str3.Substring(1);
            }
            if (str4.Length > 1)
            {
                str4 = str4.Substring(1);
            }
            else
            {
                str4 = "";
            }
            if (str5.Length <= 1)
            {
                str5 = "";
            }
            else
            {
                str5 = str5.Substring(1);
            }
            if (str6.Length > 1)
            {
                str6 = str6.Substring(1);
            }
            else
            {
                str6 = "";
            }
            if (str7.Length > 1)
            {
                str7 = str7.Substring(1);
            }
            else
            {
                str7 = "";
            }
            if (str8.Length <= 1)
            {
                str8 = "";
            }
            else
            {
                str8 = str8.Substring(1);
            }
            if (str9.Length <= 1)
            {
                str9 = "";
            }
            else
            {
                str9 = str9.Substring(1);
            }
            strSql = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) values(" + int_1;
            strSql = strSql + ",'" + string_5 + "','" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + str12 + "','ID#ID#ID#ID#ID#ID#ID#ID#ID#ID')";
            this.publicFun_0.ExecuteSql(strSql);
        }

        private void method_4(int int_1, string string_4, string string_5, string string_6)
        {
            SqlDataReader reader;
            SqlCommand command;
            SqlConnection connection2;
            string str14;
            int count;
            int num3;
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            bool flag = true;
            string str10 = "";
            int num = 0;
            string[] strArray = string_6.Split(new char[] { '#' });
            string strSql = "";
            string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
            SqlConnection selectConnection = new SqlConnection(connectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='A'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter9 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter9 = new SqlDataAdapter(string_5 + "  and (" + str10 + ")", selectConnection);
                    adapter9.Fill(dataSet, "AExamData");
                    count = dataSet.Tables["AExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["AExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str.IndexOf("#" + str14, 0) == -1)
                        {
                            str = str + str14;
                            num--;
                        }
                    }
                    adapter9.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='B'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter8 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter8 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter8.Fill(dataSet, "BExamData");
                    count = dataSet.Tables["BExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["BExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str2.IndexOf("#" + str14, 0) == -1)
                        {
                            str2 = str2 + str14;
                            num--;
                        }
                    }
                    adapter8.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='C'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter7 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter7 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter7.Fill(dataSet, "CExamData");
                    count = dataSet.Tables["CExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["CExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str3.IndexOf("#" + str14, 0) == -1)
                        {
                            str3 = str3 + str14;
                            num--;
                        }
                    }
                    adapter7.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='D'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter6 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter6 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter6.Fill(dataSet, "DExamData");
                    count = dataSet.Tables["DExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["DExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str4.IndexOf("#" + str14, 0) == -1)
                        {
                            str4 = str4 + str14;
                            num--;
                        }
                    }
                    adapter6.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='E'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter5 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter5 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter5.Fill(dataSet, "EExamData");
                    count = dataSet.Tables["EExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["EExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str5.IndexOf("#" + str14, 0) == -1)
                        {
                            str5 = str5 + str14;
                            num--;
                        }
                    }
                    adapter5.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='F'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter4 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter4 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter4.Fill(dataSet, "FExamData");
                    count = dataSet.Tables["FExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["FExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str6.IndexOf("#" + str14, 0) == -1)
                        {
                            str6 = str6 + str14;
                            num--;
                        }
                    }
                    adapter4.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='G'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter3 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter3 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter3.Fill(dataSet, "GExamData");
                    count = dataSet.Tables["GExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["GExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str7.IndexOf("#" + str14, 0) == -1)
                        {
                            str7 = str7 + str14;
                            num--;
                        }
                    }
                    adapter3.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='H'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter2 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter2 = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter2.Fill(dataSet, "HExamData");
                    count = dataSet.Tables["HExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["HExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str8.IndexOf("#" + str14, 0) == -1)
                        {
                            str8 = str8 + str14;
                            num--;
                        }
                    }
                    adapter2.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='I'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter = new SqlDataAdapter(string_5 + " and (" + str10 + ")", selectConnection);
                    adapter.Fill(dataSet, "IExamData");
                    count = dataSet.Tables["IExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["IExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str9.IndexOf("#" + str14, 0) == -1)
                        {
                            str9 = str9 + str14;
                            num--;
                        }
                    }
                    adapter.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string str13 = strArray[9].ToString().Trim();
            if (!(str13 != "0"))
            {
                str13 = "";
            }
            else
            {
                str13 = str13.Trim().Replace("_", "#") + "#";
            }
            if (str.Length <= 1)
            {
                str = "";
            }
            else
            {
                str = str.Substring(1);
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length <= 1)
            {
                str3 = "";
            }
            else
            {
                str3 = str3.Substring(1);
            }
            if (str4.Length <= 1)
            {
                str4 = "";
            }
            else
            {
                str4 = str4.Substring(1);
            }
            if (str5.Length <= 1)
            {
                str5 = "";
            }
            else
            {
                str5 = str5.Substring(1);
            }
            if (str6.Length <= 1)
            {
                str6 = "";
            }
            else
            {
                str6 = str6.Substring(1);
            }
            if (str7.Length <= 1)
            {
                str7 = "";
            }
            else
            {
                str7 = str7.Substring(1);
            }
            if (str8.Length <= 1)
            {
                str8 = "";
            }
            else
            {
                str8 = str8.Substring(1);
            }
            if (str9.Length <= 1)
            {
                str9 = "";
            }
            else
            {
                str9 = str9.Substring(1);
            }
            strSql = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) values(" + int_1;
            strSql = strSql + ",'" + string_4 + "','" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + str13 + "','ID#ID#ID#ID#ID#ID#ID#ID#ID#ID')";
            this.publicFun_0.ExecuteSql(strSql);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_3 = new HttpCookie("ExamUserLevel");
            this.httpCookie_3 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_4 = new HttpCookie("ExamDeptID");
            this.httpCookie_4 = base.Request.Cookies["ExamDeptID"];
            this.httpCookie_2 = new HttpCookie("ExamDeptName");
            this.httpCookie_2 = base.Request.Cookies["ExamDeptName"];
            if ((this.httpCookie_0 == null) || (this.httpCookie_0.Value == ""))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.httpCookie_4.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_4.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.int_0 = Convert.ToInt32(base.Request["ID"].ToString().Trim());
                this.string_2 = base.Request["RuleCust"].ToString().Trim();
                this.string_1 = this.publicFun_0.CheckString(base.Request["ExamType"].ToString().Trim());
                this.string_3 = this.publicFun_0.CheckString(base.Request["IsRead"].ToString().Trim());
                this.string_0 = this.publicFun_0.CheckString(base.Request["AddType"].ToString().Trim());
                if (!base.IsPostBack)
                {
                    if (this.string_0.Trim() != "R")
                    {
                        this.RBLExamType.Items.RemoveAt(3);
                        this.RBLExamType.Items.RemoveAt(2);
                    }
                    this.ViewState["SubjectName"] = "";
                    this.ViewState["ExamName"] = "";
                    if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='HandComb'", "ParmValue") == "1")
                    {
                        this.CBHandSet.Enabled = true;
                    }
                    else
                    {
                        this.CBHandSet.Enabled = false;
                    }
                    if (!(this.publicFun_0.ReturnPaperData() != "Yes"))
                    {
                        this.butDefault.Attributes.Add("onclick", @"javascript:{if(confirm('确认无误吗？生成试卷需要一定的时间，请耐心等待生成结果！\n\n请中途勿离开此页面！！！')==false) return false;}");
                        this.LBSelected.DataTextField = "UserName";
                        this.LBSelected.DataValueField = "UserCode";
                        this.LBSelected.DataSource = this.publicFun_0.RetrunDataView("select b.UserCode ,'['+b.UserCode+']'+b.UserName as UserName  from ExamUser a,UserInfo b where a.UserCode=b.UserCode and a.PaperID=" + this.int_0);
                        this.LBSelected.DataBind();
                        this.labSelectedUserTip.Text = "已选人员<font color=red>(" + this.LBSelected.Items.Count + ")</font>";
                        this.method_0();
                        this.method_1();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                    }
                }
            }
        }

        protected void RBLChoose_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.method_0();
            this.method_1();
        }
    }
}

